#include "stdafx.h"
//#include "PeopleCount.h"
#include "MotionDetcterClassDll.h"

#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
	IplImage *pFrame = NULL;

	bool isFristFrame = true;
	CvRect roi;

	roi.height = 370 ;
	roi.width = 400;
	roi.x = 100;
	roi.y = 100;

	CMotionDetcterClassDll  mMotionDetector;

	char filename[128];

	CvCapture* pCapture = cvCaptureFromAVI("E:\\Test video\\36.avi");
	int count = 25;
	while (1)
	{
		pFrame = cvQueryFrame(pCapture);

		if (pFrame == NULL)
		{
			count++;
			memset(filename,0,sizeof(filename));
			sprintf(filename,"E:\\Test video\\video\\04\\%d.avi",count);

			std::cout << filename << std::endl;

			pCapture = cvCaptureFromAVI(filename);

			continue;
		}

		int i = mMotionDetector.FindObject(pFrame,roi);

		//std::cout << "alarm    " <<  i << std::endl;

		cvRectangle(pFrame,cvPoint(roi.x,roi.y),cvPoint(roi.x + roi.width,roi.y + roi.height),CV_RGB(255,0,0));

		cvShowImage("video",pFrame);
		cvWaitKey(1);
	}

	cvReleaseImage(&pFrame);
	return 0;
}